function toggleComments(){
	$("#comment-group").toggle("slow");
}

function postComment(application, application_entry){
	pageURL = $("#pageURL").val();
	
	var author = $("#comment-author").val();
	var authorEmail = $("#comment-email").val();
	var authorWebSite = $("#comment-website").val();
	var commentContent = $("#comment-content").val();
	
	if(commentContent == null || commentContent == "" || author == null || author == "" || authorEmail == null || authorEmail == ""){
		$("#comment-posted-failure").dialog({
			autoOpen : true,
			width: 400,
			buttons: {
				"OK" : function(){
					$(this).dialog("close");
				}
			},
			modal : true
		});
		
		if($("#comment-posted-failure").dialog("isOpen") == false){
			$("#comment-posted-failure").dialog("open");
		}
		
		return true;
	}
	
	$.post(pageURL + "ajax/comment/add-comment/", {App : application, AppEntry : application_entry, 
		Author : author, AuthorEmail : authorEmail, AuthorWebSite : authorWebSite, CommentContent : commentContent}, function(data){
			if(data){
				$("#comment-posted-success").dialog({
						autoOpen : true,
						width: 400,
						buttons: {
							"OK" : function(){
								appendComment(data);
								$(this).dialog("close");
							}
						},
						modal : true
					});
					
					if($("#comment-posted-success").dialog("isOpen") == false){
						$("#comment-posted-success").dialog("open");
					}
					
				return true;
			}	
	});
}

function appendComment(id){
	$.post(pageURL + "ajax/comment/get-comment/"+id+"/", function(data){
		$("#comment-container").append(data);
	});
	return true
}